<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('wechat_drafts', function (Blueprint $table) {
            $table->id();
            // 文章分组id
            $table->string('group_id')->nullable()->comment('文章分组id');
            // 草稿id
            $table->string('media_id')->nullable()->comment('草稿id');
            // 状态排序
            $table->string('status')->comment('草稿状态');
            $table->integer('sort')->default(10)->comment('排序');

            // 公众号字段
            $table->string('article_type')->comment('草稿类型: 文章类型，分别有图文消息（news）、图片消息（newspic），不填默认为图文消息（news）');
            $table->string('title')->comment('草稿标题');
            $table->string('author')->nullable()->comment('草稿作者');
            $table->string('digest')->nullable()->comment('草稿摘要');
            $table->text('content')->comment('草稿内容');
            $table->string('content_source_url')->nullable()->comment('草稿内容来源');
            $table->string('thumb_media_id')->nullable()->comment('图文消息的封面图片素材id');
            $table->string('thumb_media_url')->nullable()->comment('图文消息的封面图片素材url');
            $table->string('need_open_comment')->default(1)->comment('是否需要打开评论');
            $table->string('only_fans_can_comment')->default(0)->comment('是否仅粉丝可评论');
            $table->json('image_info')->nullable()->comment('图片信息');

            // 发布字段
            $table->string('publish_time')->nullable()->comment('草稿发布时间');
            $table->string('publish_id')->nullable()->comment('草稿发布id');
            $table->string('article_id')->nullable()->comment('草稿发布id');
            $table->string('idx')->nullable()->comment('草稿索引');
            $table->string('article_url')->nullable()->comment('草稿发布url');
            $table->timestamps();

            $table->comment('微信草稿表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wechat_drafts');
    }
};
